import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/4/21
 * Time:17:04
 **/
public class Main2 {
    /**
     * 每日一题-找出n个数里最小的k个
     *
     * @param args
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String str = scanner.nextLine();
            String[] s = str.split(" ");
            int[] arr = new int[s.length - 1];
            for (int i = 0; i < s.length - 1; i++) {
                arr[i] = Integer.parseInt(s[i]);
            }

            int k = Integer.parseInt(s[s.length - 1]);
            int start = 0;
            int end = arr.length - 1;
            int index = qSort(arr, start, end);

            while (index != k) {
                if (index > k) {
                    end = index - 1;
                    index = qSort(arr, start, end);

                } else {
                    start = index + 1;
                    index = qSort(arr, start, end);
                }
            }
            Arrays.sort(arr, 0, k);
            for (int i = 0; i < k; i++) {
                System.out.print(i == k - 1 ? arr[i] : arr[i] + " ");
            }
        }
    }

    public static int qSort(int[] arr, int start, int end) {
        int s = arr[start];
        while (start < end) {
            while (start < end && arr[end] >= s) {
                end--;
            }
            arr[start] = arr[end];
            while (start < end && arr[start] < s) start++;
            arr[end] = arr[start];
        }
        arr[start] = s;
        return start;
    }
}
